<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ include file="/commons/basejs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>主页</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<meta charset="utf-8"/>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<script type="text/javascript">
		var index_layout;
		var index_tabs;
		var layout_west_tree;
		
		$(function() {
			index_layout = $('index_layout').layout({
				fit : true
		});
			index_tabs = $('#index_tabs').tabs({fit : true, border : false, tools : [{
			iconCls : 'icon-home',
			handler : function() {
				index_tabs.tabs('select', 0);
			}
		}, {
			iconCls : 'icon-refresh',
			handler : function() {
				var index = index_tabs.tabs('getTabIndex', index_tabs.tabs('getSelected'));
				var tab = index_tabs.tabs('getTab', index);
				if(tab.panel('options').closable) {
					index_tabs.tabs('close',index);
				}
			}
		}]	
		});
		
		layout_west_tree = $('#layout_west_tree').tree({url : '${path}/resource/tree', 
			parentField : 'pid',
			lines : true,
			onClick : function(node) {
				if (node.attributes.indexOf("http") >= 0){
					var url = node.attributes;
					addTab({
						title : node.text,
						url : url,
						iconCls : node.iconCls,
					});
				}else if (node.attributes) {
					var url = '${path}' + node.attributes;
					addTab({
						title : node.text,
						url : url,
						iconCls : node.iconCls
					});
				}
			}
		});
	});
	
	function addTab(params) {
		var iframe = '<iframe src="' + params.url +'" fameborder="0" style="border:0;width:100%;height:99.5%;"></iframe>';
		var t = $('#index_tabs');
		var opts = {
			title : parames.title,
			closable : true,
			iconCls : iframe,
			border : false,
			fit : true
		};
		if(t.tabs('exists',opts.title)) {
			t.tabs('select',opts.title);
		}
		else {
			t.tabs('add',opts);
		}
	}
	
	function logout() {
		$.messager.confirm('提示','确定退出？',function(r){
			if(r) {
				progressLoad();
				$.post('${path}/logout',function(result){
					if(result.success){
						progressClose();
						window.location.href='${path}';
					}
				},'json')
			}
		});
	}
	
	function editUserPwd() {
		parent.$.modalDialog({
			title : '修改密码',
			width : 300,
			height : 250,
			href : '${path}/user/editPwdPage',
			buttons : [{
				text : '确定',
				handler : function() {
					var f = parent.$.modalDialog.handler.find('#editUserPwdForm');
					f.submit();
				}
			}]
		});
	}
	</script>
  </head>
  
  <body>
  	<div id="loading" style="position : fixed; top: -50%; left: -50%; width: 200%; height: 200%; background:#fff;z-index: 100; overflow:hidden;"></div> 
  </body>
</html>
